use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::PriceChannelStrategy
///
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct PCS {
    /// 1 signal
    /// When current high price touches upper bound, returns full buy signal.
    /// When current low price touches lower bound, returns full sell signal.
    /// When both touches occure, or no toucher, then returns no signal.
    pub signal0: Option<IndicatorActionWrap>,

    /// Upper bound value
    ///Range of values is the same as the range of the source values.
    pub upper: ValueType,

    ///Lower bound value
    ///Range of values is the same as the range of the source values.
    pub lower: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct PCSConfig {
    ///period: PeriodType
    ///Main period length. Default is 20.
    ///
    ///Range in [2; PeriodType::MAX)
    pub period: PeriodType,

    /// sigma: ValueType
    /// Relative channel size. Default is 1.0.
    ///
    /// Range in (0.0; 1.0]    
    pub sigma: ValueType,
}

impl Default for PCSConfig {
    fn default() -> Self {
        Self {
            period: 20,
            sigma: 1.0,
        }
    }
}
